﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Text;
using Maticsoft.Common;
 
namespace StuEdu.Web.AttendanceCard
{
    public partial class Add : Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
                       
        }

        		protected void btnSave_Click(object sender, EventArgs e)
		{
			
			string strErr="";
			if(!PageValidate.IsNumber(txttermId.Text))
			{
				strErr+="termId格式错误！\\n";	
			}
			if(!PageValidate.IsNumber(txtgradeId.Text))
			{
				strErr+="gradeId格式错误！\\n";	
			}
			if(!PageValidate.IsDateTime(txtattendanceTime.Text))
			{
				strErr+="attendanceTime格式错误！\\n";	
			}

			if(strErr!="")
			{
				MessageBox.Show(this,strErr);
				return;
			}
			int termId=int.Parse(this.txttermId.Text);
			int gradeId=int.Parse(this.txtgradeId.Text);
			DateTime attendanceTime=DateTime.Parse(this.txtattendanceTime.Text);

			StuEdu.Model.AttendanceCard model=new StuEdu.Model.AttendanceCard();
			model.termId=termId;
			model.gradeId=gradeId;
			model.attendanceTime=attendanceTime;

			StuEdu.BLL.AttendanceCard bll=new StuEdu.BLL.AttendanceCard();
			bll.Add(model);
			Maticsoft.Common.MessageBox.ShowAndRedirect(this,"保存成功！","add.aspx");

		}


        public void btnCancle_Click(object sender, EventArgs e)
        {
            Response.Redirect("list.aspx");
        }
    }
}
